$( document ).on( "pageshow", "#endPlateList", function( event ) {
	
});
$( document ).on( "pagecreate", "#endPlateList", function( event ) {
	access_token=getQueryString("access_token");
	pageNo="1";
	pageSize="10";
	$("#wrapper_endPlateList  #pullDown").hide();
	$("#wrapper_endPlateList  #pullUp").hide();
	
	var scrollObj_endPlateList=scrollPlugLoadedOfReturn_new("wrapper_endPlateList",
			function() {
				setTimeout(function () {
					if(pageNo >= totalPage)
						return;
					pageNo++;
					loadData_endPlateList(false,scrollObj_endPlateList);
				}, 1000);	
			},
			function() {
				setTimeout(function () {
					if(pageNo>1){
						pageNo--;
						loadData_endPlateList(true,scrollObj_endPlateList);
						if(pageNo==1){
							$("#wrapper_endPlateList  #pullDown").hide();
						}
					}
				}, 1000);
			});
	
	loadData_endPlateList(true,scrollObj_endPlateList);
	//去吐槽
	$("#goEndPlate").on('click', function () {
		goTo(rootPath+"/jsp/weixin/endPlate.jsp?access_token="+access_token,false);
	});
});

function p_show(obj){
	var c = $(obj).css("white-space");
	if(c == 'normal'){
		$(obj).css({"white-space":"nowrap"});
	}else{
		$(obj).css({"white-space":"normal"});
	}
}

/**
 * 
 * @param isFresh 是否刷新
 * @param isFresh 是否初始列表
 */
function loadData_endPlateList(isFresh,scrollObj_endPlateList){
	showLoading();
	$.ajax({
	  	url: rootPath+"/user/endPlateList.do",
	  	type: "POST",
	  	dataType: "text",
		data: "access_token="+access_token+"&pageNo="+pageNo+"&pageSize="+pageSize,
	  	success: function( response ) {
	  		hideLoading();
	  		var data=$.parseJSON(response);
			if(data.state=="200"){
				totalPage=data.data.totalPage;
		  		var totalRow=data.data.totalRow;
		  		var arr=data.data.rows;
				var content = "";
				for (var i=0;i<arr.length;i++){
					var toPage=rootPath+"/jsp/weixin/endPlateInfo.jsp?toEndPlateId="+arr[i].id+"&access_token="+access_token;//去吐槽详情页
					var headerPic=rootPath+defaultHeadPic;
					if(arr[i].headImageUrl!=undefined && arr[i].headImageUrl!="" && arr[i].type=="0")
						headerPic=arr[i].headImageUrl;
					var name="匿名";
					if(arr[i].type=="0"){
						name=arr[i].emp_name;
					}
					content +='<li>\
						  <a href="#" onClick="goTo(\''+toPage+'\')" '+comStyle+'>\
							<img  '+imgStyle+' src="'+headerPic+'" class="ui-li-icon">\
							<p '+margin_top_no+'><span style="font-size:15px;">'+name+'</span><strong class="ui-li-aside_fresh" '+sideStyle+' >'+arr[i].create_timeStr+'</strong></p>\
							<p '+margin_top_6+'>'+replaceContent(arr[i].endPlateCon)+'</p>\
						  </a>\
						</li>';
				}
				if(arr.length<pageSize){
					$("#wrapper_endPlateList  #pullUp").hide();
				}else{
					$("#wrapper_endPlateList  #pullUp").show();
				}
				if(isFresh)
					$("#thelist_endPlateList").html("");
				
				//页数是2的倍数时，清空缓存列表
				if(pageNo%3==0){
					$("#wrapper_endPlateList  #pullDown").show();
					$("#thelist_endPlateList").html("");
					$("#thelist_endPlateList").append(content).listview('refresh');
				}else{
					$("#thelist_endPlateList").append(content).listview('refresh');
				}
				scrollObj_endPlateList.refresh();
			}else{
				alert_wx('fail',data.msg);
			}
	  	}
	});
}
			